package backend.importexport.controller;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import com.opensymphony.xwork2.ActionSupport;

public class FileUploadListAction extends ActionSupport {
		/**
	 * 
	 */
	private static final long serialVersionUID = 454641L;
		String parameterName;
		public String getParameterName() {
			return parameterName;
		}

		public void setParameterName(String parameterName) {
			this.parameterName = parameterName;
		}
		
		File filePath=new File("../AdvProp/source/");
		//String path = "D:/advspace/AdvProp/source"; 
		String files=null;
		 File[] listOfFiles=null;
		 List<String> lstfiles = new ArrayList<String>();
		 
		public String execute() {
			this.parameterName=this.getParameterName();
	        try {
	          
	          File folder = new File(filePath.getAbsolutePath());
	      	  listOfFiles = folder.listFiles(); 
	      	 
	      	  for (int i = 0; i < listOfFiles.length; i++) 
	      	  {
	      	 
	      	   if (listOfFiles[i].isFile()) 
	      	   {
	      	   files = listOfFiles[i].getName();
	      	 
	      	       if (files.endsWith(".csv") || files.endsWith(".CSV"))
	      	       {
	      	    	 lstfiles.add(files);
	      	        }
	      	   }
	      	  }
	            
	        } catch (Exception e) {
	            e.printStackTrace();
	            addActionError(e.getMessage());
	 
	            return INPUT;
	        }
	        return SUCCESS;
	    }

		public List<String> getLstfiles() {
			return lstfiles;
		}

		public void setLstfiles(List<String> lstfiles) {
			this.lstfiles = lstfiles;
		}

		
		
}
